package com.zone.service.service.impl;

import java.util.List;
import com.zone.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zone.service.mapper.VehicleMapper;
import com.zone.service.domain.Vehicle;
import com.zone.service.service.IVehicleService;

/**
 * 车辆管理Service业务层处理
 * 
 * @author zone
 * @date 2025-10-25
 */
@Service
public class VehicleServiceImpl implements IVehicleService 
{
    @Autowired
    private VehicleMapper vehicleMapper;

    /**
     * 查询车辆管理
     * 
     * @param id 车辆管理主键
     * @return 车辆管理
     */
    @Override
    public Vehicle selectVehicleById(Long id)
    {
        return vehicleMapper.selectVehicleById(id);
    }

    /**
     * 查询车辆管理列表
     * 
     * @param vehicle 车辆管理
     * @return 车辆管理
     */
    @Override
    public List<Vehicle> selectVehicleList(Vehicle vehicle)
    {
        return vehicleMapper.selectVehicleList(vehicle);
    }

    /**
     * 新增车辆管理
     * 
     * @param vehicle 车辆管理
     * @return 结果
     */
    @Override
    public int insertVehicle(Vehicle vehicle)
    {
        vehicle.setCreateTime(DateUtils.getNowDate());
        return vehicleMapper.insertVehicle(vehicle);
    }

    /**
     * 修改车辆管理
     * 
     * @param vehicle 车辆管理
     * @return 结果
     */
    @Override
    public int updateVehicle(Vehicle vehicle)
    {
        vehicle.setUpdateTime(DateUtils.getNowDate());
        return vehicleMapper.updateVehicle(vehicle);
    }

    /**
     * 批量删除车辆管理
     * 
     * @param ids 需要删除的车辆管理主键
     * @return 结果
     */
    @Override
    public int deleteVehicleByIds(Long[] ids)
    {
        return vehicleMapper.deleteVehicleByIds(ids);
    }

    /**
     * 删除车辆管理信息
     * 
     * @param id 车辆管理主键
     * @return 结果
     */
    @Override
    public int deleteVehicleById(Long id)
    {
        return vehicleMapper.deleteVehicleById(id);
    }
    
    /**
     * 批量新增车辆管理
     * 
     * @param vehicleList 车辆管理列表
     * @return 结果
     */
    @Override
    public int insertVehicleList(List<Vehicle> vehicleList)
    {
        int rows = 0;
        for (Vehicle vehicle : vehicleList) {
            vehicle.setCreateTime(DateUtils.getNowDate());
            rows += vehicleMapper.insertVehicle(vehicle);
        }
        return rows;
    }
    
    /**
     * 批量插入车辆数据
     *
     * @param vehicleList 车辆列表
     * @return 结果
     */
    @Override
    public int batchInsertVehicle(List<Vehicle> vehicleList) {
        return vehicleMapper.batchInsertVehicle(vehicleList);
    }
}